package com.xwh.week4;

import java.util.ArrayList;
import java.util.List;

public class Practice1 {
   static List<List<Integer>> list=new ArrayList<>();
   static List<Integer> ans=new ArrayList<>();
    public static void main(String[] args) {
        int[] nums={1,2,5,10,20,50,100};
        method(nums,200,0,0);
        System.out.println(list.size()+1);//自身也是一种；
    }
    public static void method(int[] nums,int target,int start,int comp){
        if(start>=nums.length){
            return;
        }
        if(comp>target){
            return;
        }else if(comp==target){
            list.add(new ArrayList<>(ans));
            return;
        }else{
            ans.add(nums[start]);
            comp+=nums[start];
            method(nums,target,start,comp);
            comp-= ans.get(ans.size()-1);
            ans.remove(ans.size()-1);
            method(nums,target,start+1,comp);
        }
    }
}
